import request from  '@/utils/request.js'
//获取文章详情
export function articlesGet(id){
    return request({
        url:`/v1_0/articles/${id}`
    })
}
//关注
export function userFollowings(target,bol=true){
    if(bol){
        return request({
            url:'/v1_0/user/followings',
            method:'post',
            data:{
                target
            }
        })
    }else {
        //取消关注
        return request({
            url:'/v1_0/user/followings/'+target,
            method:'delete'
        })
    }
}
//获取评论
export function commentsGet(params){
    return request ({
        url:'/v1_0/comments',
        params
    })
}
//点赞
export function articleLikings(target,bol=true){
    if(bol){
        return request ({
            url:'/v1_0/article/likings',
            method:'post',
            data:{
                target
            }
        })
    }else {
        //取消点赞
        return request ({
            url:'/v1_0/article/likings/'+ target,
            method:'DELETE'
        })
    }
}
//收藏文章
export function articleCollections(target,bol=true){
    if(bol){
        return request  ({
            url:'/v1_0/article/collections',
            method:'post',
            data:{
                target
            }
        })
    }else {
        return request({
            url:'/v1_0/article/collections/'+target,
            method:'DELETE'
        })
    }
}
//回复评论
export function commentsPost(data){
    return request ({
        url:'/v1_0/comments',
        method:'post',
        data
    })
}